1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131
|
import mpl_toolkits.axisartist as axisartist import numpy as np import matplotlib.pyplot as plt
def LabelFormat(plt): ax = plt.gca() plt.tick_params(labelsize=14) labels = ax.get_xticklabels() + ax.get_yticklabels() [label.set_fontname('Times New Roman') for label in labels] font = {'family': 'Times New Roman', 'weight': 'normal', 'size': 16, } return font
x1=3 y1=3
x2=4 y2=3
x3=1 y3=1
x4,x5,x6,x12=2,1,2,3 y4,y5,y6,y12=5,5.5,1,2.5
x7,x8,x9,x10,x11=2,-1,-2,0.5,1 y7,y8,y9,y10,y11=-1,2,3,4.5,2.2
x222=np.linspace(-1.2,4.2,100) y222=4-x222
x111=np.linspace(-0.2,5.2,100) y111=6-x111 x333=np.linspace(-2.2,3.2,100) y333=2-x333
fig = plt.figure(figsize=(6, 6))
ax = axisartist.Subplot(fig, 111)
fig.add_axes(ax)
ax.axis[:].set_visible(False)
font = LabelFormat(plt)
ax.axis["x"] = ax.new_floating_axis(0,0)
ax.axis["x"].major_ticklabels.set_fontsize(14) ax.axis["x"].major_ticklabels.set_fontname('Times New Roman') ax.axis["x"].set_axisline_style("->", size = 1.0) ax.axis["x"].label.set_fontsize(16)
ax.axis["y"] = ax.new_floating_axis(1,0) ax.axis["y"].major_ticklabels.set_fontsize(14) ax.axis["y"].major_ticklabels.set_fontname('Times New Roman') ax.axis["y"].set_axisline_style("->", size = 1.0) ax.axis["y"].label.set_fontsize(16)
ax.axis["x"].set_axis_direction("bottom") ax.axis["y"].set_axis_direction("left")
plt.plot(x2,y2,'rs') plt.text(x2+0.5,y2-0.1,r'$\mathrm{x}_2$',fontsize=16) plt.plot(x4,y4,'rs') plt.text(x4+0.5,y4-0.1,r'$\mathrm{x}_4$',fontsize=16) plt.plot(x5,y5,'rs') plt.text(x5+0.5,y5-0.1,r'$\mathrm{x}_5$',fontsize=16)
plt.plot(x1,y1,'rs') plt.text(x1+0.2,y1-0.2,r'$\mathrm{x}_1$',fontsize=16) plt.text(x1-0.2,y1+0.2,r'$\xi_1=0$',fontsize=14)
plt.plot(x6,y6,'rs') plt.text(x6+0.2,y6-0.1,r'$\mathrm{x}_6$',fontsize=16) plt.plot(x6,y6,'bs', markersize=10, markerfacecolor="none") plt.text(x6-0,y6-0.7,r'$\xi_6>1$',fontsize=14)
plt.plot(x12,y12,'rs') plt.text(x12-0.9,y12-0.1,r'$\mathrm{x}_{12}}$',fontsize=16) plt.plot(x12,y12,'rs', markersize=10, markerfacecolor="none") plt.text(x12-0.7,y12-0.7,r'$0<\xi_{12}<1$',fontsize=14)
plt.plot(x7,y7,'bo') plt.text(x7-0.7,y7-0.1,r'$\mathrm{x}_7$',fontsize=16) plt.plot(x8,y8,'bo') plt.text(x8-0.7,y8-0.1,r'$\mathrm{x}_8$',fontsize=16) plt.plot(x9,y9,'bo') plt.text(x9-0.7,y9-0.1,r'$\mathrm{x}_9$',fontsize=16)
plt.plot(x3,y3,'bo') plt.text(x3-0.7,y3-0.1,r'$\mathrm{x}_3$',fontsize=16) plt.text(x3-0.9,y3-0.7,r'$\xi_3=0$',fontsize=14)
plt.plot(x10,y10,'bo') plt.text(x10+0.2,y10-0.1,r'$\mathrm{x}_{10}$',fontsize=16) plt.plot(x10,y10,'ro', markersize=10, markerfacecolor="none") plt.text(x10-0.2,y10-0.5,r'$\xi_{10}>1$',fontsize=14)
plt.plot(x11,y11,'bo') plt.text(x11-0.7,y11-0.3,r'$\mathrm{x}_{11}$',fontsize=16) plt.plot(x11,y11,'bo', markersize=10, markerfacecolor="none") plt.text(x11-1.5,y11+0.2,r'$0<\xi_{11}<1$',fontsize=14)
plt.plot(x222,y222,'g-') plt.text(4,-1,r'$\hat y=0$',fontsize=16,rotation=45,color='g') plt.plot(x111,y111,'r-') plt.text(5,-0,r'$\hat y=+1$',fontsize=16,rotation=45,color='r') plt.plot(x333,y333,'b-') plt.text(2.5,-2.5,r'$\hat y=-1$',fontsize=16,rotation=45,color='b')
plt.text(-0.8,6.5,r'$x^{(2)}$',fontsize=16,rotation=90,color='k') plt.text(6.3,-0.8,r'$x^{(1)}$',fontsize=16,rotation=0,color='k')
plt.xlim(-2.5,6.5) plt.ylim(-2.5,6.5) plt.show()
|